#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
struct Cmd {
  string op;
  vector<int> data;
  pii x, y;
};
vector<Cmd> cmds;
bool mov(int& x, int& y, const Cmd& cmd) {
  if (cmd.op == "EX") {
    pii w = pii(x, y);
    if (w == cmd.x) {
      x = cmd.y.first, y = cmd.y.second;
    } else if (w == cmd.y) {
      x = cmd.x.first, y = cmd.x.second;
    }
  } else if (cmd.op == "DR") {
    int id =
        lower_bound(cmd.data.begin(), cmd.data.end(), x) - cmd.data.begin();
    if (id < cmd.data.size() && cmd.data[id] == x) return false;
    x -= id;
  } else if (cmd.op == "DC") {
    int id =
        lower_bound(cmd.data.begin(), cmd.data.end(), y) - cmd.data.begin();
    if (id < cmd.data.size() && cmd.data[id] == y) return false;
    y -= id;
  } else if (cmd.op == "IR") {
    int id =
        upper_bound(cmd.data.begin(), cmd.data.end(), x) - cmd.data.begin();
    x += id;
  } else {
    int id =
        upper_bound(cmd.data.begin(), cmd.data.end(), y) - cmd.data.begin();
    y += id;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int id = 0;
  while (cin >> n >> m) {
    if (!n && !m) break;
    ++id;
    if (id > 1) cout << endl;
    cout << "Spreadsheet #" << id << endl;

    // read op data
    int num;
    cin >> num;
    cmds = vector<Cmd>(num);
    rep(i, 0, num - 1) {
      cin >> cmds[i].op;
      if (cmds[i].op == "EX") {
        cin >> cmds[i].x.first >> cmds[i].x.second;
        cin >> cmds[i].y.first >> cmds[i].y.second;
      } else {
        int cnt;
        cin >> cnt;
        cmds[i].data = vector<int>(cnt);
        rep(j, 0, cnt - 1) cin >> cmds[i].data[j];
        sort(cmds[i].data.begin(), cmds[i].data.end());
      }
    }
    int t;
    cin >> t;
    while (t--) {
      int x, y;
      cin >> x >> y;
      cout << "Cell data in (" << x << ',' << y << ") ";
      bool del = false;
      for (Cmd cmd : cmds) {
        if (!mov(x, y, cmd)) {
          del = true;
          break;
        }
      }
      if (del)
        cout << "GONE\n";
      else {
        cout << "moved to (" << x << ',' << y << ")\n";
      }
    }
  }
  return 0;
}